package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.shop.ShopHouseDto;
import com.java110.intf.shop.IShopHouseInnerServiceSMO;
import com.java110.po.shop.ShopHousePo;
import com.java110.mall.shop.dao.IShopHouseServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 仓库内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopHouseInnerServiceSMOImpl extends BaseServiceSMO implements IShopHouseInnerServiceSMO {

    @Autowired
    private IShopHouseServiceDao shopHouseServiceDaoImpl;


    @Override
    public int saveShopHouse(@RequestBody ShopHousePo shopHousePo) {
        int saveFlag = 1;
        shopHouseServiceDaoImpl.saveShopHouseInfo(BeanConvertUtil.beanCovertMap(shopHousePo));
        return saveFlag;
    }

    @Override
    public int updateShopHouse(@RequestBody ShopHousePo shopHousePo) {
        int saveFlag = 1;
        shopHouseServiceDaoImpl.updateShopHouseInfo(BeanConvertUtil.beanCovertMap(shopHousePo));
        return saveFlag;
    }

    @Override
    public int deleteShopHouse(@RequestBody ShopHousePo shopHousePo) {
        int saveFlag = 1;
        shopHousePo.setStatusCd("1");
        shopHouseServiceDaoImpl.updateShopHouseInfo(BeanConvertUtil.beanCovertMap(shopHousePo));
        return saveFlag;
    }

    @Override
    public List<ShopHouseDto> queryShopHouses(@RequestBody ShopHouseDto shopHouseDto) {

        //校验是否传了 分页信息

        int page = shopHouseDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopHouseDto.setPage((page - 1) * shopHouseDto.getRow());
        }

        List<ShopHouseDto> shopHouses = BeanConvertUtil.covertBeanList(shopHouseServiceDaoImpl.getShopHouseInfo(BeanConvertUtil.beanCovertMap(shopHouseDto)), ShopHouseDto.class);

        return shopHouses;
    }


    @Override
    public int queryShopHousesCount(@RequestBody ShopHouseDto shopHouseDto) {
        return shopHouseServiceDaoImpl.queryShopHousesCount(BeanConvertUtil.beanCovertMap(shopHouseDto));
    }

    public IShopHouseServiceDao getShopHouseServiceDaoImpl() {
        return shopHouseServiceDaoImpl;
    }

    public void setShopHouseServiceDaoImpl(IShopHouseServiceDao shopHouseServiceDaoImpl) {
        this.shopHouseServiceDaoImpl = shopHouseServiceDaoImpl;
    }
}
